package util
{
	import flash.events.TimerEvent;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.utils.Timer;

	public class EffectCharTurnShow
	{
		private var timer:Timer = null;
		private var rate:Number = 0;
		private var textField:TextField = null;
		private var txtList:Array;
		private var index:int;
		
		public function EffectCharTurnShow(txt:TextField, delay:Number)
		{
			textField = txt;
			timer = new Timer(delay);
		}
		
		public function set text(tl:Array):void
		{
			txtList = tl;
		}
		
		public function start():void
		{
			reset();
			timer.addEventListener(TimerEvent.TIMER, onTimer);
			timer.reset();
			timer.start();
		}
		
		public function stop():void
		{
			timer.removeEventListener(TimerEvent.TIMER, onTimer);
			timer.stop();
		}
		
		private function onTimer(evt:TimerEvent):void
		{
			if(++index >= txtList.length)
				index = 0;
			textField.text = txtList[index] as String;
			
		}
		
		private function reset():void
		{
			index = -1;
			textField.text = txtList[0] as String;
		}
	}
}